package codeGen.core.jpa;

import codeGen.core.FreemarkerUtil;
import codeGen.core.model.FieldModel;
import codeGen.core.model.TableModel;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.List;

public class JpaRepositoryGen {
    public static void genCode(TableModel tModel, File output) {
        try {
            List<FieldModel> primes = tModel.getPrimtives();

            File model_class = new File(output, tModel.getToClassName() + "Repository.java");
            FreemarkerUtil.genResource("jpa/repository.ftl", new FileOutputStream(model_class), tModel);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
